package com.ricchieri.bean;

import java.io.Serializable;
import java.util.List;

import com.ricchieri.common.BusinessSettings;
import com.ricchieri.model.Reservation;
import com.ricchieri.model.ScheduleCharter;
import com.ricchieri.model.ScheduleCharterExpense;

public class TravelStatusBean implements Serializable {
	private static final long serialVersionUID = -1391705720397538835L;

	private int peopleTravelled;
	private int peopleNotTravelled;
	private int peoplePaid;
	private int peopleNotPaid;
	private double totalExpenses;
	private double total;
	private double totalCash;
	private int paidVoucher;
	private int paidCC;
	private int paidCash;

	public TravelStatusBean(ScheduleCharter scheduleCharter, List<ScheduleCharterExpense> expenses) {
		calculateTotal(scheduleCharter, expenses);
	}

	private void calculateTotal(ScheduleCharter scheduleCharter,
			List<ScheduleCharterExpense> expenses) {
		for (Reservation reservation : scheduleCharter.getActiveReservations()) {
			if(reservation.getTravelStatus()) {
				peopleTravelled = peopleTravelled + 1;
			} else {
				peopleNotTravelled = peopleNotTravelled + 1;
			}
			
			if(reservation.getPaymentStatus()) {
				peoplePaid = peoplePaid +1;
				if(reservation.obtainMeanPaymentStatus().getDescription().equals(BusinessSettings.MEAN_PAYMENT_CASH)) {
					totalCash = totalCash + reservation.getCost();
					paidCash = paidCash + 1;
				} else if(reservation.obtainMeanPaymentStatus().getDescription().equals(BusinessSettings.MEAN_PAYMENT_CC)) {
					paidCC = paidCC + 1;
				} else if(reservation.obtainMeanPaymentStatus().getDescription().equals(BusinessSettings.MEAN_PAYMENT_VOUCHER)) {
					paidVoucher = paidVoucher + 1;
				}
			} else {
				peopleNotPaid = peopleNotPaid + 1;
			}
		}
		
		for (ScheduleCharterExpense scheduleCharterExpense : expenses) {
			totalExpenses = scheduleCharterExpense.getAmount() + totalExpenses;
		}
		total = totalCash - totalExpenses;
	}

	public int getPeopleTravelled() {
		return peopleTravelled;
	}

	public void setPeopleTravelled(int peopleTravelled) {
		this.peopleTravelled = peopleTravelled;
	}

	public int getPeopleNotTravelled() {
		return peopleNotTravelled;
	}

	public void setPeopleNotTravelled(int peopleNotTravelled) {
		this.peopleNotTravelled = peopleNotTravelled;
	}

	public int getPeoplePaid() {
		return peoplePaid;
	}

	public void setPeoplePaid(int peoplePaid) {
		this.peoplePaid = peoplePaid;
	}

	public int getPeopleNotPaid() {
		return peopleNotPaid;
	}

	public void setPeopleNotPaid(int peopleNotPaid) {
		this.peopleNotPaid = peopleNotPaid;
	}

	public double getTotalExpenses() {
		return totalExpenses;
	}

	public void setTotalExpenses(double totalExpenses) {
		this.totalExpenses = totalExpenses;
	}

	public double getTotal() {
		return total;
	}

	public void setTotal(double total) {
		this.total = total;
	}

	public double getTotalCash() {
		return totalCash;
	}

	public void setTotalCash(double totalCash) {
		this.totalCash = totalCash;
	}

	public int getPaidVoucher() {
		return paidVoucher;
	}

	public void setPaidVoucher(int paidVoucher) {
		this.paidVoucher = paidVoucher;
	}

	public int getPaidCC() {
		return paidCC;
	}

	public void setPaidCC(int paidCC) {
		this.paidCC = paidCC;
	}

	public int getPaidCash() {
		return paidCash;
	}

	public void setPaidCash(int paidCash) {
		this.paidCash = paidCash;
	}
}
